<?php
/**
 * @filesource modules/event/controllers/IndexController.php
 * @author Hoang
 * @abstract : List of actions in order
 *   - new
 *   - view
 *   - edit
 *   - delete
 *   - search
 */ 
class Gome_IndexController extends Clu_Controller_Action_Hvn
{
	public $m,$c;//, $mPlace, $mArticle;
	public $tl;
	public function init()
	{
		//require_once (APP_PATH.'/modules/category/Model/Category.php');
		//require_once (APP_PATH.'/modules/news/Model/News.php');
		//require_once (APP_PATH.'/modules/article/Model/Article.php');
		//require_once (APP_PATH.'/modules/user/Model/User.php');
		$this->c = new category_Model_Category();
		$this->mArticle = new article_Model_Service();
		$this->n = new Model_News();
		parent::init();
		
	}
	
	public function indexAction()
	{
		$sess = new Zend_Session_Namespace(CLU_NS);

 		$this->renderToHolder('index/home_address_background.phtml', false, null, 4,1);
 		$this->renderToHolder('index/search.phtml', false, null, 4,2); 
 		$this->renderToHolder('index/ads.phtml', false, null, 4,3); 
		$vision = $this->n->getNewsData(1, true, 'array'); //vision
		$this->view->vision = $vision;
		$ph = $this->n->getNewsData(2, true, 'array');
		$this->view->philosophy = $ph;

		$m = $this->n->getNewsData(3, true, 'array');
		$this->view->mission = $m;
		
		$this->view->language = $sess->viewLang;
		$loginRequest = array(
                                'module' => 'user',
                                'controller' => 'block',
                                'action' => 'login',
                                'regionId' => 1,
                                'boxWeight' => 1,
								'theme' => 'gome'
                );
		$this->addMiniAction($loginRequest);
		$this->renderToHolder('index/company_vision.phtml', false, null, 4, 4);
		$this->renderToHolder('index/global_connection.phtml', false, null, 4, 5);
		$this->generateCommonBoxes();		
	}
	
	public function generateCommonBoxes()
	{
		$latest = $this->n->getLatestRecruitments();
		$this->view->latest = $latest;
		$this->renderToHolder('index/latest_news.phtml', false, null, 5, 1);
		$this->renderToHolder('index/product.phtml', false, null, 5, 2);
		$this->renderToHolder('index/footer.phtml', false, null, 6, 1); //footer
	}
	
	public function newsAction() 
	{
		$sess = new Zend_Session_Namespace(CLU_NS);
		$this->view->language = $sess->viewLang;
		
		$id = $this->_request->getParam('id');
		$news = $this->n->getNewsData($id, true, 'array');
		
		$this->view->news = $news;
		$this->view->placeholder('currentMenu')->set($this->_request->getParam('menu'));
		$this->view->placeholder('currentIndex')->set($this->_request->getParam('index'));
		$loginRequest = array(
                                'module' => 'user',
                                'controller' => 'block',
                                'action' => 'login',
                                'regionId' => 1,
                                'boxWeight' => 1,
								'theme' => 'gome'
                );
		$this->addMiniAction($loginRequest);
        $this->renderToHolder('index/news.phtml', false, null, 4,1);
        $this->generateCommonBoxes();
	}
	
	public function listNewsAction() 
	{
		$sess = new Zend_Session_Namespace(CLU_NS);
		$this->view->language = $sess->viewLang;
		$latest = $this->n->getLatestRecruitments();
		$this->view->latest = $latest;
		$this->view->placeholder('currentMenu')->set($this->_request->getParam('menu'));
		$this->view->placeholder('currentIndex')->set($this->_request->getParam('index'));
		$this->renderToHolder('index/list_news.phtml', false, null, 4,1);
        $this->generateCommonBoxes();
	}
	
	public function generatePaginator($select, $pageNumber, $itemsPerPage, $pageRange, $style)
    {
        $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
        $paginator->setItemCountPerPage($itemsPerPage);
        $paginator->setCurrentPageNumber($pageNumber);
        $paginator->setPageRange($pageRange);
        Zend_Paginator::setDefaultScrollingStyle($style);
        return $paginator;
    }

	public function successAction()
    {
         $this->view->tid =  $this->_request->getParam("tid");
         $this->renderToHolder( 'common/success.phtml');  
    }
}
?>
